package com.qiang.util;

import com.alibaba.fastjson.JSON;
import com.qiang.model.Node;

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @package: com.qiang.util
 * @title: Node
 * @projectName: burning
 * @description: //TODO
 * @author zhuhongqiang3
 * @date:  2020-08-07 16:36
 * @version: V1.0
 * @retrun com.qiang.util.burning
 */
public class NodeTest {

    public static void main(String[] args) throws InterruptedException {
        Integer[] element = new Integer[]{1, 2, 3, 4, 8, 9, 5, 6, 0, 10};
        Integer k = 4;
        Map<Integer,Integer> map = new HashMap();

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < element.length; i++) {
            for (int m = 1; m < element.length; m++) {
                Integer ei = element[i];
                Integer em = element[m];
                Integer result = ei + em;
                if (k.equals(result) &&!map.containsKey(ei) && !map.containsValue(ei) && !set.contains(ei)) {
                    map.put(ei,em);
                    set.add(ei);
                    set.add(em);
                }
            }
        }

        int l = 0;
        Integer[][] er = new Integer[map.size()][2];
        for (Integer key : map.keySet()){
            Integer [] one = new Integer[]{key,map.get(key)};
            er[l] = one;
            l ++;
        }


        System.out.println(JSON.toJSONString(er));

    }


    //迭代
    public ListNode reverseList(ListNode head) {
        ListNode prev = null;
        ListNode curr = head;
        while (curr != null) {
            ListNode nextTemp = curr.next;
            curr.next = prev;
            prev = curr;
            curr = nextTemp;
        }
        return prev;
    }

    //递归





}
